using System;
using Headspring.Training.Domain.Model;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace Headspring.Training.Domain.UnitTests.Model
{
	[TestFixture]
	public class WorkOrderTester
	{
		[Test]
		public void PropertiesShouldInitializeToProperDefaults()
		{
			WorkOrder workOrder = new WorkOrder();
			Assert.That(workOrder.Id, Is.EqualTo(Guid.Empty));
			Assert.That(workOrder.Title, Is.EqualTo(string.Empty));
			Assert.That(workOrder.Description, Is.EqualTo(string.Empty));
			Assert.That(workOrder.Status, Is.EqualTo(WorkOrderStatus.Draft));
            Assert.That(workOrder.Number, Is.EqualTo(null));
			Assert.That(workOrder.Creator, Is.EqualTo(null));
			Assert.That(workOrder.Assignee, Is.EqualTo(null));
			Assert.That(workOrder.CreatedDate, Is.EqualTo(null));
			Assert.That(workOrder.CompletedDate, Is.EqualTo(null));
		}




		[Test]
		public void ToStringShouldReturnWONumber()
		{
			WorkOrder order = new WorkOrder();
			order.Number = "456";
			Assert.That(order.ToString(), Is.EqualTo("Work Order 456"));
		}
        [Test]
        public void PropertiesShouldGetAndSetValuesProperly()
        {
            WorkOrder workOrder = new WorkOrder();
            Guid guid = Guid.NewGuid();
            Employee creator = new Employee();
            Employee assignee = new Employee();
            DateTime createdDate = new DateTime(2000, 1, 1);
            DateTime completedDate = new DateTime(2000, 10, 1);

            workOrder.Id = guid;
            workOrder.Title = "Title";
            workOrder.Description = "Description";
            workOrder.Status = WorkOrderStatus.Complete;
            workOrder.Number = "Number";
            workOrder.Creator = creator;
            workOrder.Assignee = assignee;
            workOrder.CreatedDate = createdDate;
            workOrder.CompletedDate = completedDate;

            Assert.That(workOrder.Id, Is.EqualTo(guid));
            Assert.That(workOrder.Title, Is.EqualTo("Title"));
            Assert.That(workOrder.Description, Is.EqualTo("Description"));
            Assert.That(workOrder.Status, Is.EqualTo(WorkOrderStatus.Complete));
            Assert.That(workOrder.Number, Is.EqualTo("Number"));
            Assert.That(workOrder.Creator, Is.EqualTo(creator));
            Assert.That(workOrder.Assignee, Is.EqualTo(assignee));
            Assert.That(workOrder.CreatedDate, Is.EqualTo(createdDate));
            Assert.That(workOrder.CompletedDate, Is.EqualTo(completedDate));

        }

        [Test]
        public void ShouldShowFriendlyStatusValuesAsStrings()
        {
            WorkOrder workOrder = new WorkOrder();
            workOrder.Status = WorkOrderStatus.Assigned;

            Assert.That(workOrder.FriendlyStatus, Is.EqualTo("Assigned"));
        }
	}
}
